from turbogears import widgets, validators

class CommentFields(widgets.WidgetsList):
    author_name = widgets.TextField(validator=validators.NotEmpty(), label="Name")
    author_email = widgets.TextField(validator=validators.Email(not_empty=True), label="Email")
    author_url = widgets.TextField(label="URL")
    content = widgets.TextArea(validator=validators.NotEmpty(), attrs=dict(rows=30, cols=70))
    post_id = widgets.HiddenField(validator=validators.Int(not_empty=True))
    
comment_form = widgets.TableForm(fields=CommentFields(),
                        name="w_commentform",
                        action="/comment",
                        method="post",
                        submit_text="Comment!")
                        
                        
class PostDisplayWidget(widgets.Widget):
    template = 'simpleblog.templates.post_display_widget'
    params = ['post']
post_display = PostDisplayWidget()